<template>
    <div class="simple-settings">
        <h2 class="green-title">系统设置</h2>
        <button @click="goBack" class="back-button">
            <svg class="icon" viewBox="0 0 24 24">
                <path d="M20 11H7.8l5.6-5.6L12 4l-8 8 8 8 1.4-1.4L7.8 13H20v-2z" />
            </svg>
        </button>
        <div class="menu">
            <button @click="toggleMusic" class="menu-item">
                <svg class="icon" viewBox="0 0 24 24">
                    <path v-if="musicEnabled" d="M3 9h6l5-5v16l-5-5H3V9zm14 0h4v6h-4v-6z" />
                    <path
                        v-else
                        d="M3 9h6l5-5v2.8L7.2 9H5v6h2.2l4.8 4.8V21l-5-5H3V9zm14-2h2v8h-2V7z"
                    />
                </svg>
                媒体音乐 {{ musicEnabled ? '开启中' : '已关闭' }}
            </button>

            <button @click="switchAccount" class="menu-item">
                <svg class="icon" viewBox="0 0 24 24">
                    <path
                        d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 4c1.7 0 3 1.3 3 3s-1.3 3-3 3-3-1.3-3-3 1.3-3 3-3zm0 14.5c-3 0-5.5-1.3-7-3.3 0-2 4-3.2 7-3.2s7 1.2 7 3.2c-1.5 2-4 3.3-7 3.3z"
                    />
                </svg>
                切换账号
            </button>

            <button @click="logout" class="menu-item logout">
                <svg class="icon" viewBox="0 0 24 24">
                    <path d="M5 2h8v2H5v16h8v2H3V2h2zm12 7h-2V7h-2v2h2v8h-2v2h4v-2h-2V9z" />
                </svg>
                退出登录
            </button>
        </div>
    </div>
</template>

<script>
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '@/store/user'
import { computed } from 'vue'

export default {
    setup() {
        const route = useRoute()
        const store = useUserStore()
        const router = useRouter()

        const musicEnabled = ref(true)
        let route_name = computed(() => route.name)

        const toggleMusic = () => {
            musicEnabled.value = !musicEnabled.value
            // 实际控制代码
        }

        // 新增返回方法
        const goBack = () => {
            router.go(-1)
        }

        const switchAccount = () => {
            if (confirm('切换账号将返回登录页，是否继续？')) {
                router.push('/')
            }
            store.fullLogout()
        }
        const logout = () => {
            if (confirm('确定要退出登录吗？')) {
                router.push('/')
            }
            store.fullLogout()
        }
        return {
            route_name,
            logout,
            toggleMusic,
            switchAccount,
            goBack,
            musicEnabled,
        }
    },
}
</script>

<style scoped>
.simple-settings {
    position: relative;
    padding: 2rem;
    background: #0a0a0a;
    min-height: 100vh;
    color: #e0e0e0;
}

/* 霓虹标题效果 */
.green-title {
    color: #00ff88;
    font-size: 2.5rem;
    margin: 2rem 0 3rem;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    position: relative;
    padding-bottom: 1rem;
}

.green-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #00ff88, transparent);
}

.back-button {
    position: absolute;
    left: 1.5rem;
    top: 1.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-button:hover {
    background: rgba(0, 255, 136, 0.1);
    transform: translateX(-4px) scale(1.1);
}

.back-button .icon {
    fill: #00ff88;
    filter: drop-shadow(0 0 4px rgba(0, 255, 136, 0.3));
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 480px;
    margin: 0 auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-size: 1.1rem;
    color: #e0e0e0;
    position: relative;
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.1), transparent);
    transition: 0.5s;
}

.menu-item:hover {
    border-color: #00ff88;
    transform: translateX(10px);
    box-shadow: 0 8px 24px rgba(0, 255, 136, 0.1);
}

.menu-item:hover::before {
    left: 100%;
}

.icon {
    width: 28px;
    height: 28px;
    margin-right: 1.5rem;
    fill: #00ff88;
    transition: all 0.3s ease;
}

.menu-item:hover .icon {
    filter: drop-shadow(0 0 8px #00ff88);
    transform: scale(1.1);
}

.logout:hover {
    border-color: #ff4757;
    color: #ff4757;
    box-shadow: 0 8px 24px rgba(255, 71, 87, 0.1);
}

.logout:hover .icon {
    fill: #ff4757;
    filter: drop-shadow(0 0 8px #ff4757);
}

/* 响应式调整 */
@media (min-width: 640px) {
    .menu-item {
        font-size: 1.2rem;
        padding: 2rem;
    }

    .icon {
        width: 32px;
        height: 32px;
    }
}

/* 背景粒子效果 */
.simple-settings::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: radial-gradient(
        circle at 50% 50%,
        rgba(0, 255, 136, 0.05) 0%,
        transparent 60%
    );
    pointer-events: none;
    z-index: -1;
}
</style>
